package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductCateService;
import com.mall.shopping.IProductService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.RecommendResponse;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Hu
 * @create 2021-09-29 17:40
 * @Description
 */

@RestController
@RequestMapping("/shopping")
public class RecommendController {

    @Reference(timeout = 30000, retries = 2, check = false)
    IProductService iProductService;


    @RequestMapping("/recommend")
    @Anoymous
    //recommend 不传惨
    public ResponseData recommendList() {
        RecommendResponse response = iProductService.getRecommendGoods();

        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());

    }

}
